package com.demo.thymeleafdemo.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;

/**
 * @author ddone
 * @date 2024/3/13-09:44
 */
@WebServlet("/param")
public class ParamServlet extends  ViewBaseServlet{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ArrayList<String> nameList = new ArrayList<>(Arrays.asList("张三", "李四", "王五"));
        req.setAttribute("nameList",nameList);
        req.setAttribute("request","request数据");
        req.getSession().setAttribute("session","session数据");
        req.getServletContext().setAttribute("application","application数据");
        this.processTemplate("scope",req,resp);
    }
}
